package com.jinit.rpc.provider.service;

import com.jinit.rpc.api.pojo.User;
import com.jinit.rpc.api.service.UserService;
import com.jinit.rpc.provider.annotation.RpcService;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * 用户服务实现
 *
 * @author JInit
 * @date 2021-08-29
 */
@Service
@RpcService
public class UserServiceImpl implements UserService {

    Map<Integer, User> userMap = new HashMap<>(16);

    @Override
    public User getUserById(int id) {
        if (userMap.isEmpty()) {
            userMap.put(1, new User(1, "用户01"));
            userMap.put(2, new User(2, "用户02"));
        }
        return userMap.get(id);
    }
}
